package controllers

import java.nio.file.Files
import dao._
import implicits.Implicits._

import javax.inject.Inject
import play.api.cache.SyncCacheApi
import play.api.i18n.I18nSupport
import play.api.mvc.{AbstractController, ControllerComponents}
import tool.Pojo.Info
import tool.{FormTool, Tool}
import utils.Utils

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.concurrent.duration._
import scala.language.postfixOps
import upickle.default._

/**
 * Created by yz on 3/7/2020
 */
class CollectController @Inject()(cc: ControllerComponents)(
  implicit val userDao: UserDao,
  implicit val cache: SyncCacheApi,
  implicit val modedao: ModeDao,
  implicit val collectDao: CollectDao,
) extends AbstractController(cc) with I18nSupport {

  def getCollect = Action.async { implicit request =>
    val userId = Tool.getUserId
    collectDao.select(userId).map { x =>
      val array = x.softs
      Ok(writeJs(array))
    }
  }

}
